package deepr.core;


import deepr.anno.SchemaType;
import deepr.anno.Type;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Data
public class PropertyData {

    private String name;
    private Type type;
    private Class<?> handler;
    private Object handlerArgs;
    private boolean isPrimaryKey;

    private Class<?> schema = null;
    private Class<?> relation = null;
    private String relationLabel = null;
    private String relationObject = null;
    private Type point = null;
    private String forProperty = null;

    public void setIsPrimaryKey(boolean isPrimaryKey) {
        this.isPrimaryKey = isPrimaryKey;
    }

    public boolean isSchema() {
        return schema != null;
    }

    public boolean isPg() {
        SchemaData schemaData = getSchemaData();
        return schemaData != null && schemaData.getSchemaType() == SchemaType.PG;
    }

    public SchemaData getSchemaData() {
        if (schema != null) {
            return SchemaManager.getSchemaData(schema);
        }
        return null;
    }

}
